import React from 'react';

import {connect} from 'react-redux';
import get_sub_state from './get_sub_state';
import actions from './actions';

class UiList extends React.Component{
    constructor(props){
        super(props);
    }
    render(){
        let lis = this.props.list.map((item)=><li key={item.id} onClick={()=>this.props.select(item.id)} style={{backgroundColor:item.selected?"yellow":"white"}}>{item.name}</li>);
        return <ul>
            {lis}
        </ul>;
    }
}

export default connect(get_sub_state, actions)(UiList);
